#include "KTcpSocket.h"
#include "KSockAddress.h"

SOCKET KTcpSocket::accept(KIpAddress &addrRemote)
{
    assert(isAlive());
    return ::accept(handle(), addrRemote.name(), addrRemote.pLength());
}

bool KTcpSocket::connect(const KIAddress &addrRemote)
{
    assert(isAlive() && !addrRemote.isNull());
    return ::connect(handle(), addrRemote.name(), addrRemote.length()) != SOCKET_ERROR;
}

bool KTcpSocket::listen(int backlog)
{
    assert(isAlive());
    return ::listen(handle(), backlog) != SOCKET_ERROR;
}